<template>
  <view>
    <view>
      <uni-popup ref="alertDialog" type="dialog" animation="true">
        <uni-popup-dialog :type="msgType" :cancelText="cancelText" :confirmText="confirmText" :title="confirmTitle" :content="content" @confirm="dialogConfirm"
                          @close="dialogClose"></uni-popup-dialog>
      </uni-popup>
    </view>
    <view>
      <!-- 提示信息弹窗 -->
      <uni-popup ref="message" type="message">
        <uni-popup-message :type="msgType" :message="confirmTitle" :duration="2000"></uni-popup-message>
      </uni-popup>
    </view>
  </view>
</template>
<script>
export default {
  name: "xpop",
  data() {
    return {
      msgType:"success",
      cancelText:"关闭",
      confirmText:"确定",
      confirmTitle:"提示",
      content:"",
      call:null,
      t:null
    }
  },
  methods: {
    messageToggle(t,type,title) {
      this.t = t;
      if(type)this.msgType = type;
      if(title)this.confirmTitle = title;
      this.$refs.message.open()
    },
    dialogToggle(t,type,title,content,call,confirmText,cancelText) {
      this.t = t;
      if(type)this.type = type;
      if(title)this.confirmTitle = title;
      if(content)this.content = content;
      if(confirmText)this.confirmText = confirmText;
      if(cancelText)this.cancelText = cancelText;
      if(call)this.call = call;
      this.$refs.alertDialog.open()
    },
    dialogConfirm() {
      if(this.call){
        var t =this.t;
        var calla = this.call;
        t[calla]();
        // this.$parent.dialogConfirm();
      }
    },
    dialogClose() {
      console.log('点击关闭')
    },
  },
  // props: ["msgType","messageText"],
};
</script>
<style lang="scss" scoped>

</style>
